# -*- coding: UTF-8 -*-
"""
@File    ：第三周_第一节_作业.py
@Author  ：Super
@Date    ：2020/12/29
@Desc    ：
"""
from home_work import HomeWork


def for_demo():
    """
    for 循环 计数
    计算 1+2+3+4...+100的总和
    """
    sum = 0
    for i in range(1, 101):
        sum += i
    print(sum)


def while_demo():
    """
    while 循环 计数
    计算 1+2+3+4...+100的总和
    """
    i = 1
    sum = 0
    while i <= 100:
        sum += i
        i += 1
    print(sum)


def fib_for(n):
    a, b = 0, 1
    for _ in range(n):
        a, b = b, a + b
        yield a


def fib_while(n):
    a, b = 0, 1
    while n > 0:
        a, b = b, a + b
        n -= 1
        yield a


if __name__ == '__main__':
    for_demo()
    while_demo()
    for i in fib_for(10):
        print(i, end=' ')
    for i in fib_while(10):
        print(i, end=' ')
    hw = HomeWork()
    print(hw.add(1,1))
    print(hw.divide(1,1))
    print(hw.double_div(1,1))
    print(hw.excract(1))
    print(hw.ride(1,1))
    print(hw.subtract(1,1))
    print(hw.surplus(1,1))
